package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.apis.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理" ,tags = "channel", description = "频道管理API")
public class AdChannelController implements AdChannelControllerApi {
    @Autowired
    AdChannelService adChannelService;
    @Override
    @PostMapping("list")
    @ApiOperation(value = "查询频道信息")
    @ApiImplicitParam(name = "channelDto",type ="ChannelDto",value = "查询名称",required = true)
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto channelDto) {
        return adChannelService.findByNameAndPage(channelDto);
    }

    @Override
    @PostMapping("save")
    @ApiOperation(value = "添加频道")
    @ApiImplicitParam(name = "adChannel",type ="AdChannel",required = true)
    public ResponseResult save(@RequestBody AdChannel adChannel) {
        return adChannelService.add(adChannel);
    }

    @Override
    @PostMapping("edit")
    @ApiOperation(value = "修改频道")
    @ApiImplicitParam(name = "adChannel",type ="AdChannel",required = true)
    public ResponseResult edit(@RequestBody AdChannel adChannel) {
        return adChannelService.edit(adChannel);
    }

    @Override
    @GetMapping("del")
    @ApiOperation(value = "删除频道")
    @ApiParam(name = "id",type = "Integer",required = true)
    public ResponseResult del(Integer id) {
        return adChannelService.del(id);
    }
}
